<?php
defined('IN_XLP') or exit('Access Denied');
$Document = array(
    'pageid'   => 'article-edit', //页面标示
    'pagename' => '编辑文章', //当前页面名称
    'mycss'    => array('../jquery-ui/css/smoothness/jquery-ui-1.10.0.custom.min','content/webuploader'), //加载的css样式表
    'myjs'     => array('content/jquery.smoothConfirm'), //加载的js脚本
    'footerjs' => array('content/fuelux/fuelux', '../ueditor/editor_config', '../ueditor/editor.min','content/combodate/moment.min','../jquery-ui/js/jquery-ui-1.10.0.custom.min'),
    'head'     => true, //加载头部文件
);

include getTpl('header', 'public');
?>
<style>
.w80{width:80px;text-align:center;}
.hide{display:none;}
.removeFile{float:left;margin:115px 0 20px -85px;cursor: pointer;color: #5191d1;}
#facebox{z-index: 1000;}
.facebox_overlayBG{z-index: 999;}
</style>
<!--顶部导航 开始-->
<?php include getTpl('top', 'public');?>
<!--顶部导航 结束-->
<!--左侧菜单 开始-->
<?php include getTpl('nav', 'public');?>
<!--左侧菜单 结束-->
<!--主体 开始-->
<!-- content -->
	<section id="content">
		<section class="main padder"> 
		<div class="clearfix"> 
			<h4><i class="fa fa-edit"></i>编辑文章</h4> 
		</div> 
		<div class="row"> 
		 <div class="col-sm-12"> 
			<section class="panel"> 
			 <div class="panel-body"> 
				<form class="form-horizontal" id="goodsAddForm" method="post" >
				<div class="form-group">
		          <label class="col-sm-1 control-label">所属分类</label>
		          <div class="col-sm-2">
		              <select id="cid" name="cid" class="form-control">
		                  <option value="-1">选择分类</option>
		                  <?php foreach ($article_type as $k => $v): ?>
		                  <option value="<?php echo $k ?>" <?php if($k == $info['cid']){ echo 'selected'; } ?>><?php echo $v ?></option>
		                  <?php endforeach ?>
		              </select>
		          </div>
		        </div> 
			 	<div class="form-group"> 
					<label class="col-sm-1 control-label">文章标题</label> 
					<div class="col-sm-3"> 
						<input type="text" name="title" id="title" placeholder="文章标题" class="form-control" data-required="true" value="<?php echo $info['title']; ?>" />
					</div>
			 	</div>

			 	<div class="form-group"> 
		            <label class="col-sm-1 control-label">文章详情</label> 
		            <div class="col-sm-5"> 
		              <script type="text/plain" id="editor">
		              	<?php echo htmlspecialchars_decode($info['content']); ?>
		              </script>
		            </div>
		        </div>
				
				<div class="form-group">
					<label class="col-sm-1 control-label">是否上架</label> 
					<div class="row">
						<div class="col-xs-1 radio m-l-large"><label class="radio-custom"> <input type="radio" name="status" value="1" <?php if(isHave($info['status']) && $info['status'] == 1) echo 'checked="checked"' ?>/> <i class="fa fa-circle-o"></i>上架</label></div>
						<div class="col-xs-1 radio m-l-large"><label class="radio-custom"> <input type="radio" name="status" value="0" <?php if(!isHave($info['status'])) echo 'checked="checked"' ?> /> <i class="fa fa-circle-o"></i>下架</label></div>
					</div>
				 </div>
				 <div class="form-group"> 
					<div class="col-sm-9 col-lg-offset-3"> 
						<input type="hidden" name="id" value="<?php echo $info['id']; ?>">
						<input type="hidden" name="content" id="goods_body">
						<div class="col-sm-1"><button type="submit" id="sub-ok" data-loading-text="正在提交..." class="btn btn-primary">保存</button></div>
						<button type="button" class="btn btn-white col-md-offset-1">取消</button> 
					</div> 
			
				 </div> 
				</form> 
			 </div> 
			</section>
		 </div> 
		</div> 
	 </section> 

	</section> 
	<!--/ content --> 
<!--主体 结束-->
<script>
var fixedImagePath			= '';
var uploadUrl				= "<?php echo U('goods/upload');?>";
var UEDITOR_HOME_URL = '<?php echo LOCAL_PUBLIC_PATH; ?>ueditor/';

$(function(){

	var msg_editor = new UE.ui.Editor({initialFrameWidth: 690});
	msg_editor.render("editor");

	$('#goodsAddForm').submit(function(){
		$("#goods_body").val(msg_editor.getContent());
		if (!$('#title').val()){
			Msg.error('请输入标题');
			resetSubmit("#sub-ok",'提交');
			return false;
		}

		Msg.loading();
		$.post('<?php echo U('article/edit');?>',$(this).serialize(),function(result){
			Msg.hide();
			resetSubmit("#sub-ok",'提交');
			if (result.status==1){
			Msg.ok(result.info);
		}else{
			Msg.error(result.info);
		}
		},'json');
		return false;
	});
})
</script>
<?php include getTpl('footer', 'public'); ?>